//
//  PATimeLineInfo.m
//  PAMobileWallet
//
//  Created by Gavin Zhang on 7/14/13.
//  Copyright (c) 2013 平安付. All rights reserved.
//

#import "PATimeLineInfo.h"
#import "PAUserInfo.h"
@implementation PATimeLineInfo

@synthesize createdDateStr          = _createdDateStr;
@synthesize lastTradeAmount         = _lastTradeAmount;
@synthesize lastTradeDirection      = _lastTradeDirection;
@synthesize targetInfo              = _targetInfo;
@synthesize lastTradeStatus         = _lastTradeStatus;
@synthesize updateDateStr           = _updateDateStr;

- (id)initWithDic:(NSDictionary *)dic
{
    self = [super init];
    if (self) {
        if ([dic objectForKey:k_createdDate]) self.createdDateStr = [dic objectForKey:k_createdDate];
        if ([dic objectForKey:k_lastTradeAmount]) self.lastTradeAmount = [[dic objectForKey:k_lastTradeAmount] floatValue];
        if ([dic objectForKey:k_lastTradeDirection]) self.lastTradeDirection = [[dic objectForKey:k_lastTradeDirection] integerValue];
                if ([dic objectForKey:k_targetInfo]) self.targetInfo = [[PAUserInfo alloc] initWithDic:[dic objectForKey:k_targetInfo]];
        if ([dic objectForKey:k_lastTradeStatus]) self.lastTradeStatus = [[dic objectForKey:k_lastTradeStatus] integerValue];
        if ([dic objectForKey:k_updateDate]) self.updateDateStr = [dic objectForKey:k_updateDate];
    }
    return self;
}

- (void)encodeWithCoder:(NSCoder *)aCoder{
    [aCoder encodeObject:_createdDateStr forKey:@"createdDateStr"];
    [aCoder encodeFloat:_lastTradeAmount forKey:@"lastTradeAmount"];
    [aCoder encodeInteger:_lastTradeDirection forKey:@"lastTradeDirection"];
    [aCoder encodeObject:_targetInfo forKey:@"targetInfo"];
    [aCoder encodeInteger:_lastTradeStatus forKey:@"lastTradeStatus"];
    [aCoder encodeObject:_updateDateStr forKey:@"updateDateStr"];
}

- (id)initWithCoder:(NSCoder *)aDecoder{
    self = [super init];
    if (self) {
        _createdDateStr = [aDecoder decodeObjectForKey:@"createdDateStr"];
        _lastTradeAmount = [aDecoder decodeFloatForKey:@"lastTradeAmount"];
        _lastTradeDirection = [aDecoder decodeIntegerForKey:@"lastTradeDirection"];
        _targetInfo = [aDecoder decodeObjectForKey:@"targetInfo"];
        _lastTradeStatus = [aDecoder decodeIntegerForKey:@"lastTradeStatus"];
        _updateDateStr = [aDecoder decodeObjectForKey:@"updateDateStr"];
    }
    return self;
}

@end
